#!/bin/sh

##
## This is an example "discovery agent" as described in the GENESI-DR project
## plan. Given some third-party ad-hoc tool that creates RDF/XML files suitable
## for ingestion by the duetopia registry/catalogue, and deposits them in a 
## spool directory, this script takes these files and uploads them.
##

SPOOLDIR=/var/spool/rdf

for f in `find $SPOOLDIR -type f -name \*.rdf`; do
	##
	## any required validation may be done at this stage
	##

	## upload the file to the catalogue
	curl -s -d @$f http://catalog.terradue.com/duetopia/register/dataset/import/rdf/
	## only remove the spool file if the upload was successful
	if test $? -eq 0; then
		rm -f $f
	fi
done
